/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.workingtimemanager.urb.globals;

import de.workingtimemanager.urb.entities.Project;
import de.workingtimemanager.urb.entities.User;
//TODO change user,project,workday to just one user
/**
 *
 * @author CK05102
 */
@Deprecated
public class Globals {

    private static Globals instance = new Globals();
    private static User activeUser;

    private Globals() {
    }

    public static Globals getInstance() {
        return instance;
    }

    public static User getActiveUser() {
        return activeUser;
    }

    public static void setActiveUser(User user) {
        activeUser = user;
    }

    public static Project getActiveProject(){
        for(Project p : activeUser.getProjects()){
            if(p.isActive()){
                return p;
            }
        }
        return null;
    }
    
    public static Project getProjectByName(String name){
        for(Project p : activeUser.getProjects()){
            if(p.getProjectName().equals(name)){
                return p;
            }
        }
        return null;
    }
    
    public static void setActiveProject(Project project){
        for(Project p : activeUser.getProjects()){
            if(p.equals(project)){
                p.setActive(true);
            }
        }
    }
}
